package zct.proj.customView;

import java.util.ArrayList;

import zct.proj.util.DrawUtil;
import zct.proj.util.IniParser;
import zct.proj.pojo.EquipmentInfo;
import zct.proj.pojo.StationInfo;
import zct.proj.pojo.StationSummary;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.widget.AbsoluteLayout;

@SuppressWarnings("deprecation")
public class ViewScroll extends AbsoluteLayout
{
	private TouchView tv;
	StationInfo sInfo;
	DrawUtil drawUtil;

	public ViewScroll(Context context)
	{
		super(context);

		// 读取配置文件信息
//		sInfo = IniParser.getStationInfo("BQY2.ini");
//		sInfo = IniParser.getStationInfo(context);
//		StationSummary ss = sInfo.getStationSummary();
//		
//    	drawUtil = new DrawUtil(context, ss, 1);
//		
////    	// 在大图上画出网点
////    	drawUtil.drawNet();
//    	// 绘制各个控件
//    	drawUtil.drawControls(sInfo.getCtlList());
    	
		
    	// 将站场图缩小到屏幕中间完全显示
//		int defWidth = ((Activity)context).getWindowManager().getDefaultDisplay().getWidth();
//		int defHeight = ((Activity)context).getWindowManager().getDefaultDisplay().getHeight();
//		double scaleX = (double) defWidth / drawUtil.getTolWidth();
//		double scaleY = (double) defHeight / drawUtil.getTolHeight();
//		double scale = Math.min(scaleX, scaleY);
//        int imgW = (int) (drawUtil.getTolWidth() * scale);
//        int imgH = (int) (drawUtil.getTolHeight() * scale);
//        int layout_w = imgW > defWidth ? defWidth : imgW;
//        int layout_h = imgH > defHeight ? defHeight : imgH;
//        if(layout_w == defWidth || layout_h == defHeight) {
//        	tv.setScaleType(ScaleType.FIT_XY);
//        }
        
//		StationInfo sInfo = IniParser.getStationInfo(context);
//		StationSummary ss = sInfo.getStationSummary();
//    	drawUtil = new DrawUtil(context, ss, 1);
//    	// 获得所有控件信息
////    	ArrayList<EquipmentInfo> sbList = sInfo.getCtlList();
//    	// 绘制各个控件
////    	drawUtil.drawNet();
//    	drawUtil.drawControls(sInfo.getCtlList());
////    	Bitmap cacheImage = drawUtil.getCacheBitmap();
		
    	// 生成imageview控件
//    	tv = new TouchView(context);
////    	tv.setImageBitmap(drawUtil.getCacheBitmap());
////    	tv.setLayoutParams(new AbsoluteLayout.LayoutParams(1140, 670, 20, 20));
////        tv.setLayoutParams(new AbsoluteLayout.LayoutParams(layout_w, layout_h, (defWidth - layout_w) / 2, (defHeight - layout_h) / 2));
//        this.addView(tv);
	}

	public void setTVClick() {
		tv.drawSome();
	}
//	public TouchView getTV() {
//		return tv;
//	}
}
